#ifndef FLYWEIGHT_PATTERN_H
#define FLYWEIGHT_PATTERN_H

#include <string>
#include <map>

using namespace std;

class FlyShape
{
public:
    virtual ~FlyShape() {}
    virtual void draw() = 0;
};

class FlyCircle : public FlyShape
{
public:
    FlyCircle(string color);
    ~FlyCircle() {}

    void setX(int x);
    void setY(int y);
    void setRadius(int radius);

    void draw() override;

private:
    string color;
    int x, y, radius;
};

class FlyShapeFactory
{
public:
    ~FlyShapeFactory();

    FlyShape* getCircle(string color);

private:
    map<string, FlyShape*> circleMap;
};

#endif // FLYWEIGHT_PATTERN_H

/*
    vector<string> colors = { "Red", "Green", "Blue", "White", "Black" };
    cout << colors.size() << endl;
    FlyShapeFactory* factory = new FlyShapeFactory();

    for(int i = 0; i < 10; i++)
    {
        FlyCircle* circle = dynamic_cast<FlyCircle*>(factory->getCircle(colors.at((int)rand() % colors.size())));
        circle->setX(int(rand()*100));
        circle->setY(int(rand()*100));
        circle->setRadius(100);
        circle->draw();
    }
    */
